<div class="p15">
    {include file="common/breadcrumb" /}
    <div class="pl20 pr50 mt30">
        <form class="am-form"  name="access" method="post" action="{:url('access',array('id'=>$roleId))}">
            <div class="am-checkbox">
                <label>
                    <input type="checkbox" id="J_checkall"> 全选
                </label>
            </div>
            <hr class="am-text-primary">
            <ul class="authadmin-item-list clearfix">
                {$ruleList}
            </ul>
            <div class="am-form-group pl30 mt30">
				<input type="submit" class="am-btn am-btn-primary  am-btn-block">
            </div>
            <form>
    </div>
    <script type="text/javascript">
    $(function() {
        $(".authadmin-item-list .J_parent_top,.authadmin-item-list .J_parent").on("click", function() {
            var $this = $(this);
            var $parents = $this.parents(".treeview").eq(0);
            var $checkbox = $parents.find(".J_checkbox");

            $checkbox.prop({
                checked: $this.prop("checked"),
            })
        });

        $(".authadmin-item-list .J_single").on("click", function() {
            var $this = $(this);
            var $parents = $this.parents(".treeview");
            var checked = $(this).prop("checked");
            if (!checked) {
                //没全中  父元素 还有全选 打钩要去掉
                $parents.children('.item').find('.J_checkbox').prop({
                    checked: checked
                })
            } else {
                //选中
            }

        });

        


        $("#J_checkall").on("click", function() {
            var $this = $(this);
            var checked = $(this).prop("checked");
            $(".authadmin-item-list .J_checkbox").prop({
                checked: checked
            })

        });


        $(".J_toggleshow").on("click",function(){
        	var $this = $(this);
        	var $parent=$this.parent().parent(".treeview");
        	var $sibling=$parent.children('.authadmin-item-list');
        	if($sibling.is(":visible")){
        		$sibling.slideUp('fast');
        		$this.text("展开");
        	}else{
        		$sibling.slideDown('fast');
        		$this.text("收起");
        	}
        })




    })
    </script>
</div>
<style type="text/css">
.authadmin-item-box {
    border: 1px solid #e2e2e2;
    margin-bottom: 20px;
}

.authadmin-item-box .caption {
    background: #ECECEC;
    padding: 0 10px;
    height: 30px;
    line-height: 30px;
}

.authadmin-item-list .fwnormal {
    font-weight: normal;
}

.authadmin-item-list {
    padding: 10px 30px 0;
    margin: 0;
}

.authadmin-item-list li.last{
	float:left; 
}

.authadmin-item-list>li {
    border: 1px solid #e2e2e2;
    margin-bottom: 10px;
}

.authadmin-item-list>li>.item {
    padding: 3px 10px;
    background: #f7f7f7;
}

.authadmin-item-list .mr5 {
    margin-right: 5px !important;
}
</style>